package survivalcraft.common;

import java.util.logging.Logger;

import net.minecraft.src.Block;
import net.minecraft.src.BlockLeaves;
import net.minecraft.src.Item;
import net.minecraft.src.ItemTool;
import net.minecraft.src.Material;
import net.minecraft.src.World;

public class GlobalModifications {

	static Logger log = Logger.getLogger("ForgeModLoader");
	
	public static void modifyToolEffectiveness() {

		setAllHarvestLevels();
		hardenExistingBlocks(100F);

	}



	private static void setAllHarvestLevels() {
		
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreIron, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreCoal, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreDiamond, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreEmerald, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreGold, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreLapis, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.oreRedstone, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockDiamond, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockEmerald, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockGold, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockLapis, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.blockSteel, "pickaxe", 3);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.stone, "pickaxe", 2);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.cobblestone, "pickaxe", 1);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.glowStone, "pickaxe", 1);
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.netherrack, "pickaxe", 2);
		
		net.minecraftforge.common.MinecraftForge.setBlockHarvestLevel(Block.wood, "axe", 2);
		//Material.wood.setIsToolNotRequired(false);
		
		//protected method. The harvest level check is bypassed if the material
		//does not require a specific tool. May need to edit another base class for this.
		
	}

	private static void hardenExistingBlocks(float multiplyHardness) {

		for (Block block : net.minecraft.src.Block.blocksList) {
			if (block != null) {
				float blockHardness = block.getBlockHardness(null, 0, 0, 0);
				blockHardness *= multiplyHardness;
				log.info(String.valueOf(blockHardness));
				log.info(block.toString());
				block.setHardness(blockHardness);
			}
		}
		for (Item item : net.minecraft.src.Item.itemsList) {
			if (item instanceof ItemTool) {
				ItemTool itemTool = (ItemTool) item;
				itemTool.efficiencyOnProperMaterial *= multiplyHardness;
			}
		}
	}

}
